/**
 * Copyright (c) 2000-2013 Liferay, Inc. All rights reserved.
 *
 * This library is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Lesser General Public License as published by the Free
 * Software Foundation; either version 2.1 of the License, or (at your option)
 * any later version.
 *
 * This library is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
 * details.
 */

package com.hellodoctor.slayer.model.impl;

import com.hellodoctor.slayer.model.Profile;

import com.liferay.portal.kernel.util.StringBundler;
import com.liferay.portal.model.CacheModel;

import java.io.Externalizable;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;

import java.util.Date;

/**
 * The cache model class for representing Profile in entity cache.
 *
 * @author Shahbaj
 * @see Profile
 * @generated
 */
public class ProfileCacheModel implements CacheModel<Profile>, Externalizable {
	@Override
	public String toString() {
		StringBundler sb = new StringBundler(17);

		sb.append("{profileId=");
		sb.append(profileId);
		sb.append(", userId=");
		sb.append(userId);
		sb.append(", isDoctor=");
		sb.append(isDoctor);
		sb.append(", speciality=");
		sb.append(speciality);
		sb.append(", qualification=");
		sb.append(qualification);
		sb.append(", practicingSince=");
		sb.append(practicingSince);
		sb.append(", createDate=");
		sb.append(createDate);
		sb.append(", modifiedDate=");
		sb.append(modifiedDate);
		sb.append("}");

		return sb.toString();
	}

	@Override
	public Profile toEntityModel() {
		ProfileImpl profileImpl = new ProfileImpl();

		profileImpl.setProfileId(profileId);
		profileImpl.setUserId(userId);
		profileImpl.setIsDoctor(isDoctor);
		profileImpl.setSpeciality(speciality);
		profileImpl.setQualification(qualification);
		profileImpl.setPracticingSince(practicingSince);

		if (createDate == Long.MIN_VALUE) {
			profileImpl.setCreateDate(null);
		}
		else {
			profileImpl.setCreateDate(new Date(createDate));
		}

		if (modifiedDate == Long.MIN_VALUE) {
			profileImpl.setModifiedDate(null);
		}
		else {
			profileImpl.setModifiedDate(new Date(modifiedDate));
		}

		profileImpl.resetOriginalValues();

		return profileImpl;
	}

	@Override
	public void readExternal(ObjectInput objectInput) throws IOException {
		profileId = objectInput.readLong();
		userId = objectInput.readLong();
		isDoctor = objectInput.readBoolean();
		speciality = objectInput.readInt();
		qualification = objectInput.readInt();
		practicingSince = objectInput.readInt();
		createDate = objectInput.readLong();
		modifiedDate = objectInput.readLong();
	}

	@Override
	public void writeExternal(ObjectOutput objectOutput)
		throws IOException {
		objectOutput.writeLong(profileId);
		objectOutput.writeLong(userId);
		objectOutput.writeBoolean(isDoctor);
		objectOutput.writeInt(speciality);
		objectOutput.writeInt(qualification);
		objectOutput.writeInt(practicingSince);
		objectOutput.writeLong(createDate);
		objectOutput.writeLong(modifiedDate);
	}

	public long profileId;
	public long userId;
	public boolean isDoctor;
	public int speciality;
	public int qualification;
	public int practicingSince;
	public long createDate;
	public long modifiedDate;
}